package leetcode.datastructure.str;

import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Map;

public class Program12IntegerToRomanNum {

    public Program12IntegerToRomanNum() {
    }

    public String intToRoman(int num) {

        return person(num);
//        return office(num);
    }
    public String person(int num) {
        // 逐级递减
        int[] values = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
        String[] symbols = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};


        StringBuilder roman = new StringBuilder();
        for (int i = 0; i < values.length; ++i) {
            int value = values[i];
            String symbol = symbols[i];
            while (num >= value) {
                num -= value;
                roman.append(symbol);
            }
            if (num == 0) {
                break;
            }
        }
        return roman.toString();
    }

    public static void main(String[] args) {
        Program12IntegerToRomanNum obj = new Program12IntegerToRomanNum();
        System.out.println(obj.intToRoman(3749));
        System.out.println(obj.intToRoman(58));
        System.out.println(obj.intToRoman(1994));
    }
}
